//配置路由
import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);
//引入路由组件
import Home from '../pages/Home'
import Search from '../pages/Search'
import Register from '../pages/Register'
import Login from '../pages/Login'

let originPush=VueRouter.prototype.push;
let originReplace=VueRouter.prototype.replace;
VueRouter.prototype.push=function (location,resolve,reject) {
    if(resolve&&reject){
        originPush.call(this,location,resolve,reject)
    }else{
        originPush.call(this,location,() => {},() => {})
    }
    
};
VueRouter.prototype.replace = function(location,resolve,reject){
    if(resolve && reject){
        originReplace.call(this,location,resolve,reject)
    }else{
        originReplace.call(this,location,()=>{},()=>{})
    }
};

export default new VueRouter({
    routes:[
        {
            name:'zhuye',
            path:'/home',
            component:Home,
            meta:{show:true}
        },
        {
            name:'sousuo',
            path:'/search/:keyword?',
            component:Search,
    // props: route => ({keyword3: route.params.keyword, keyword4: route.query.keyword2}),

            meta:{show:true}

        },
        {
            name:'denglu',
            path:'/login',
            component:Login,
            meta:{show:false}

        },
        {
            name:'zhuce',
            path:'/register',
            component:Register,
            meta:{show:false}

        },
        //重定向
        {
            path:'*',
            redirect:"/home"
        }
    ]
})